Separating merged array of arithmetic and geometric series [closed]

Posted by user1814037 on Programmers See other posts from Programmers or by user1814037
Published on 2012-12-07T07:47:16Z Indexed on 2012/12/09 17:18 UTC
Read the original article Hit count: 199

Filed under:

Possible Duplicate:
Separating merged array of arithmetic and geometric series

My friend asked me an interseting question.

Given an array of positive integers in increasing order. Seperate them in two series, an arithmetic sequence and geometric sequence. The given array is such that a solution do exist.

  • The union of numbers of the two sequence must be the given array.
  • Both series can have common elements i.e. series need not to be disjoint.
  • The ratio of the geometric series can be fractional.

Example:
Given series : 2,4,6,8,10,12,25
AP: 2,4,6,8,10,12
GP: 4,10,25

I tried taking few examples but could not reach a general way. Even tried some graph implementation by introducing edges if they follow a particular sequence but could not reach solution.

© Programmers or respective owner

Related posts about math